﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Boom.Navigation
{
    public abstract class GameBasic:DrawableGameComponent
    {
        private List<GameComponent> _Component;
        private bool _Pause;

        public bool Pause
        {
            get { return _Pause; }
            set { _Pause = value; }
        }

        public List<GameComponent> Component
        {
            get { return _Component; }
        }

        public GameBasic(Game Mygame)
            : base(Mygame)
        {
            _Component = new List<GameComponent>();
            Enabled = false;
            Visible = false;
        }

        public virtual void Show()
        {
            Enabled = true;
            Visible = true;
        }

        public virtual void Hide()
        {
            Enabled = false;
            Visible = false;
        }

        public override void Initialize()
        {
            for (int i = 0; i < _Component.Count; i++)
            {
                _Component[i].Initialize();
            }
            base.Initialize();
        }

        public override void Update(GameTime gameTime)
        {
            if (!_Pause && Enabled)
            {
                for (int i = 0; i < _Component.Count; i++)
                {
                    _Component[i].Update(gameTime);
                }
            }
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            if (Enabled)
            {
                for (int i = 0; i < _Component.Count; i++)
                {
                    GameComponent temp = _Component[i];
                    if ((temp is DrawableGameComponent) && ((DrawableGameComponent)temp).Enabled)
                        ((DrawableGameComponent)temp).Draw(gameTime);
                }
                base.Draw(gameTime);
            }
        }
    }
}
